import type { Recordable } from '@vben/types';

import type { Page } from '../base';

import { requestClient } from '#/api/request';

export namespace LimbDeviceParamApi {
  export interface LimbDeviceParam {
    [key: string]: any;
    id: string;
    name: string;
    description?: string;
    meta?: string;
    status?: number;
    isDeleted?: boolean;
    createdAt?: string;
    updatedAt?: string;
    deletedAt?: string;
    models?: any[];
  }

  export interface DeviceParamUpdateInput {
    status?: number;
    isDeleted?: boolean;
    createdAt?: string;
    updatedAt?: string;
    deletedAt?: string;
    description?: string;
    meta?: string;
    name?: string;
  }
}

/**
 * 获取设备参数列表
 */
async function getDeviceParamList(params: Recordable<any>) {
  return requestClient.get<Page<LimbDeviceParamApi.LimbDeviceParam>>(
    '/limb/device-param/list',
    { params },
  );
}

/**
 * 创建设备参数
 * @param data 设备参数数据
 */
async function createDeviceParam(
  data: LimbDeviceParamApi.DeviceParamUpdateInput,
) {
  return requestClient.post('/limb/device-param', data);
}

/**
 * 更新设备参数
 *
 * @param id 设备参数 ID
 * @param data 设备参数数据
 */
async function updateDeviceParam(
  id: string,
  data: LimbDeviceParamApi.DeviceParamUpdateInput,
) {
  return requestClient.put(`/limb/device-param/${id}`, data);
}

/**
 * 删除设备参数
 * @param id 设备参数 ID
 */
async function deleteDeviceParam(id: string) {
  return requestClient.delete(`/limb/device-param/${id}`);
}

export {
  createDeviceParam,
  deleteDeviceParam,
  getDeviceParamList,
  updateDeviceParam,
};
